<template>
    <div id="pagination">
        <el-pagination
                :page-size="pageSize"
                background
                layout="prev, pager, next"
                :total="count"
                @current-change="handleCurrentChange">
        </el-pagination>
    </div>
</template>
<!--分页器-->
<script>
    import {Pagination} from "element-ui";
    import {post} from "../../request/AxiosMAX";
    export default {
        name: "Pagination",
        components: {
            "el-pagination": Pagination
        },
        props:{
            path:{
                type:String
            },
            item:{
                type: Object
            },
            count:{
                type:Number,
                default:1
            }
        },
        data(){
            return {
                pageSize:this.item.pageSize
            }
        },
        methods:{
            handleCurrentChange(currentPage) {
                //封装参数
                this.item.startNumber=currentPage;
                //发送post请求
                post(this.path,this.item).then(res=>{
                    if(res.code===0){
                        this.$emit("transfer",res);
                    }
                });
            }
        }
    }
</script>

<style scoped>
    #pagination{
        margin-top: 20px;
        /*margin-left: 200px;*/
        margin-bottom: 20px;
    }
</style>
